package org.stvd.service.workflow.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.stvd.core.dto.QueryResult;
import org.stvd.entities.workflow.WfIndex;
import org.stvd.repository.workflow.WfIndexDao;
import org.stvd.service.base.impl.BaseServiceImpl;
import org.stvd.service.workflow.WfIndexService;

@Service("WfIndexService")
public class WfIndexServiceImpl extends BaseServiceImpl<WfIndex> implements WfIndexService {

    @Resource(name = "WfIndexDao")
    private WfIndexDao wfIndexDao;
    
    public QueryResult<WfIndex> getQueryResult(int start, int limit) {
        return wfIndexDao.getQueryResult(start, limit);
    }

    public WfIndex findByProcInstId(String procInstId) {
        return wfIndexDao.findByProcInstId(procInstId);
    }
    
    @Transactional
    public void delete(String procInstId) {
        WfIndex wfIndex = wfIndexDao.findByProcInstId(procInstId);
        if(wfIndex != null){
            wfIndexDao.delete(WfIndex.class, wfIndex.getId());
        }
    }
}
